""" The Guardian newspaper question was something like:

'What is the fiftieth term in the sequence 1, 11, 21, 1112, 3112, ... ?'
"""

x = 1
num = 50

for i in range(num):
    xstr = str(x)
    numerals = set(xstr)
    temp = [str(xstr.count(n)) + n for n in sorted(numerals)]
    x = int(''.join(temp))
    print x, 'sequence number:', i+1
